1 <?php
2 session_start();
3 include(
"header.php");
4 include(
"sidebar.php");
5 ?>
6
7 <script type=
"text/javascript">
8 function isNumberKey(evt)
9       {
10
11          
var charCode = (evt.which) ? evt.which : event.keyCode
12         
//alert(charCode);
13          
if (charCode > 63 && charCode < 92 )
14          {
15          
return true;
16      }
17      
else if (charCode > 96 && charCode < 123 )
18          {
19          
return true;
20      }
21      
else
22      {
23                              alert(
"should be alphabet");
24         
return false;
25      }
26      }
27 function validate()
28 {

29 if
(document.form1.fname.value=="")
30 {
31     alert(
"Enter First Name");
32     document.form1.fname.focus();
33     
return false;
34 }

35 if
(document.form1.lname.value=="")
36 {
37     alert(
"Enter Last Name");
38     document.form1.lname.focus();
39     
return false;
40 }

41 if
(document.form1.emailid.value=="")
42 {
43     alert(
"Enter Email ID");
44     document.form1.emailid.focus();
45     
return false;
46 }
47     ml = document.form1.emailid.
value;
48         pos1 = ml.indexOf(
"@")
49         pos = ml.indexOf(
" ")
50         pos2 = (pos1+
1)
51         server = ml.substring(pos2);
52         server_pos = server.lastIndexOf(
".")
53         reqtype = server.substring(server_pos+
1)
54         type_end = reqtype.substring(reqtype.length-
1)
55
56 if
(ml.length<8)
57     {
58             document.form1.emailid.focus();
59             document.form1.emailid.
select();
60             alert(
"emailid length cannot be less than 8 characters");
61             
return false;
62     }
63          
if(ml.indexOf("@")==-1)
64         {
65             document.form1.emailid.focus();
66             document.form1.emailid.
select();
67             alert(
"The emailid Address must contain '@' sign");
68             
return false;
69         }
70          
if(pos1<1)
71         {
72             document.form1.emailid.focus();
73             document.form1.emailid.
select();
74             alert(
"emailid address cannot start with '@' sign");
75             
return false;
76         }
77         
if(ml.indexOf(".")==-1)
78         {
79             document.form1.emailid.focus();
80             document.form1.emailid.
select();
81             alert(
"The emailid Address must contain '.' sign");
82             
return false;
83         }
84         
if(pos!=-1)
85         {
86             document.form1.emailid.focus();
87             document.form1.emailid.
select();
88             alert(
"The emailid Address cannot contain spaces");
89             
return false;
90         }
91         
if(server.indexOf("@")!=-1)
92         {
93             document.form1.emailid.focus();
94             document.form1.emailid.
select();
95             alert(
"A valid emailid must contain only one '@' sign");
96             
return false;
97         }
98         
if(server.indexOf(".")==0)
99         {
100             document.form1.emailid.focus();
101             document.form1.emailid.
select();
102             alert(
"There should some text between '@' and '.' sign");
103             
return false;
104         }
105         
if(reqtype=="")
106         {
107             document.form1.emailid.focus();
108             document.form1.emailid.
select();
109             alert(
"emailid Id should end with character(like .com,.net,.org)");
110             
return false;
111         }
112         
if(type_end.toUpperCase()<"A" || type_end.toUpperCase()>"Z")
113         {
114             document.form1.emailid.focus();
115             document.form1.emailid.
select();
116             alert(
"emailid Id should not end with number or symbol");
117             
return false;
118         }

119
120
121
122 if
(document.form1.password.value=="")
123 {
124     alert(
"Enter Password");
125     document.form1.password.focus();
126     
return false;
127 }

128 if
(document.form1.confpass.value=="")
129 {
130     alert(
"Please confirm the Password");
131     document.form1.confpass.focus();
132     
return false;
133 }

134 if
(document.form1.address.value=="")
135 {
136     alert(
"Enter the Address");
137     document.form1.address.focus();
138     
return false;
139 }

140 if
(document.form1.city.value=="")
141 {
142     alert(
"Enter the City");
143     document.form1.city.focus();
144     
return false;
145 }

146 if
(document.form1.zip.value=="")
147 {
148     alert(
"Enter the Zip");
149     document.form1.zip.focus();
150     
return false;
151 }

152 if
(document.form1.phone.value=="")
153 {
154     alert(
"Enter Phone No");
155     document.form1.phone.focus();
156     
return false;
157 }

158 if
(document.form1.mobile.value=="")
159 {
160     alert(
"Enter Mobile Number");
161     document.form1.mobile.focus();
162     
return false;
163 }
164 }
165 </script>
166 <?php
167 include(
"dbconnection.php");
168         
if(isset($_SESSION[empid]))
169     {
170         header(
"Location: empaccount.php");
171     }

172 if
(isset($_SESSION[custid]))
173 {
174     header(
"Location: account.php");
175 }
176 $dt= date(
"Y-m-d");
177 if
(isset($_POST["submit"]))
178 {
179 $sql =
"insert into customer(fname,lname,emailid ,password,createddate,contactno1,contactno2,address,city,zipcode) values('$_POST[fname]','$_POST[lname]','$_POST[email]','$_POST[password]','$dt','$_POST[phone]','$_POST[mobile]','$_POST[address]','$_POST[city]','$_POST[zipcode]')";
180 if
(!mysql_query($sql,$con))
181   {
182   die(
'Error: ' . mysql_error());
183   }
184 $ctins = mysql_affected_rows();
185 }
186 ?>
187         
188                             
189         <div id=
"main">
190             
191             <a name=
"TemplateInfo"></a>
192             <h1>Customer Registration</h1>
193
194 <?php

195 if
($ctins == 1)
196 {
197     echo
"<center><b>Custmer registered Successfully...</b></center><br>";
198     echo
"<center><b><a href='login.php'>Click here to Login.</a></b></center>";
199 }

200 else

201 {
202     ?>
203         <form id=
"form1" name="form1" method="post" action="" onsubmit="return validate()">
204             <table width=
"522" border="0">
205               <tr bgcolor=
"#CCFFFF">
206                 <th height=
"33" scope="row" align="left">User information:</th>
207                 <td>&nbsp;</td>
208               </tr>
209               <tr>
210                 <th width=
"170" height="33" scope="row">First Name</th>
211                 <td width=
"247">
212                   <label
for="lname"></label>
213                   <input name=
"fname" type="text" id="fname" size="35" onKeyPress="return isNumberKey(event)"/>
214                 </td>
215               </tr>
216               <tr>
217                 <th height=
"37" scope="row">Last Name
218                   <label
for="lname"></label></th>
219                 <td><input name=
"lname" type="text" id="lname" size="35" onKeyPress="return isNumberKey(event)" /></td>
220               </tr>
221               <tr>
222                 <th height=
"36" scope="row">Email Id</th>
223                 <td><label
for="email"></label>
224                 <input name=
"email" type="text" id="email" size="35" /></td>
225               </tr>
226               <tr>
227                 <th height=
"34" scope="row">Password</th>
228                 <td><label
for="password"></label>
229                 <input name=
"password" type="password" id="password" size="35" /></td>
230               </tr>
231               <tr>
232                 <th height=
"40" scope="row">Confirm Password</th>
233                 <td><label
for="confpass"></label>
234                 <input name=
"confpass" type="password" id="confpass" size="35" /></td>
235               </tr>
236               <tr align=
"left" bgcolor="#CCFFFF">
237                 <th height=
"29" colspan="2" scope="row"><u>Contact information</u></th>
238               </tr>
239               <tr>
240                 <th height=
"37" scope="row">Address</th>
241                 <td><textarea name=
"address" cols="35" id="address"></textarea></td>
242               </tr>
243               <tr>
244                 <th height=
"37" scope="row">City</th>
245                 <td><input name=
"city" type="text" id="city" size="35" /></td>
246               </tr>
247               <tr>
248                 <th height=
"37" scope="row">Zip code</th>
249                 <td><input name=
"zipcode" type="text" id="zipcode" size="35" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
250               </tr>
251               <tr>
252                 <th height=
"37" scope="row">Phone No</th>
253                 <td><label
for="date"></label>
254                 <input name=
"phone" type="text" id="phone" size="35" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
255               </tr>
256               <tr>
257                 <th scope=
"row">Mobile No</th>
258                 <td><label
for="mobile"></label>
259                 <input name=
"mobile" type="text" id="mobile" size="35" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
260               </tr>
261               <tr>
262                 <th scope=
"row">&nbsp;</th>
263                 <td><br /> <input type=
"submit" name="submit" id="submit" value="Register" /></td>
264               </tr>
265           </table>
266         </form>
267       <?php
268 }
269 ?>
270             <p>&nbsp;</p>
271 <br />
272                                             
273         </div>
274         
275 <!-- wrap ends here -->
276 </div>
277         
278 <?php
279 include(
"footer.php");
280 ?>


Gõ tìm kiếm nhanh...